/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.se2.meteocal.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import static javax.persistence.TemporalType.DATE;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Ugo
 */
@Entity
@NamedQueries({
       @NamedQuery(name = EventNotification.findByEventNotSeen, query = "SELECT e FROM EventNotification e WHERE e.event= :event AND e.seen=FALSE "),
       @NamedQuery(name = EventNotification.findByEvent, query = "SELECT e FROM EventNotification e WHERE e.event= :event"),

})
public class EventNotification implements Serializable {
    private static final long serialVersionUID = 1L;
    public static final String findByEventNotSeen = "EventNotification.FindByEventNotSeen";
    public static final String findByEvent = "EventNotification.FindByEvent";

    @OneToOne
    @Id
    private Event event;
     
    @Column(name = "NEWDATE")
    @Temporal(DATE)
    @NotNull(message = "May not be empty")
    private Date newdate;
    
    @Column(name = "SEEN")
    @NotNull(message = "May not be empty")
    private Boolean seen;
    
    public EventNotification(){
        
    }
    
    public EventNotification(Event event,Date newdate){
        this.event=event;
        this.newdate=newdate;
        this.seen=false;
    }
    
    public Event getEvent(){
        return this.event;
    }
    
    public void setEvent(Event event){
        this.event=event;
    }
    
    public Date getNewdate(){
        return this.newdate;
    }
    
    public void setNewdate(Date newdate){
        this.newdate=newdate;
    }
   
    public Boolean isSeen(){
        return this.seen;
    }
    
    public void setSeen(Boolean seen){
        this.seen=seen;
    }
    
}
